#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <UIKit/UIApplication.h>
#import <LockInfo/Plugin.h>

#import "framework/FWCommon.h"
#import "framework/FWDetailListEntry.h"
#import "framework/FWDetailListSection.h"
#import "framework/FWPlugin.h"

#import "PICommon.h"
#import "PITaskDebug.h"
#import "PIAlarm.h"
#import "PITask.h"
#import "PITaskStatus.h"
#import "PITaskPlugin.h"
#import "PIContext.h"


@implementation PITaskDebug


// ******************************************************************************************
#pragma mark -
#pragma mark Initialisation and object management


// ******************************************************************************************
#pragma mark -
#pragma mark Accessing records from the database

- (NSArray*)detailSectionsForListPage:(NSObject *)page key:(NSObject*)key application:(FWApplication *)application
{  
    PITaskStatus* info = (PITaskStatus*)application.info;
    PITaskPlugin* plugin = (PITaskPlugin*)application.fwPlugin;

    NSArray* infoSect = [NSArray arrayWithObjects:
                          [FWDetailListEntry entryWithTitle:@"⚡ Last Update" value:FWDebugTimeStringForUTCDate(plugin.lastUpdate)],
                         [FWDetailListEntry entryWithTitle:@"Total Items"
                                                     value:[[NSNumber numberWithInt:info.itemsReturnedCount] stringValue]],
                          [FWDetailListEntry entryWithTitle:@"Items Filtered"
                                                      value:[[NSNumber numberWithInt:info.itemsFilteredCount] stringValue]],
                          [FWDetailListEntry entryWithTitle:@"Items With Details"
                                                      value:[[NSNumber numberWithInt:info.itemsWithDetailsCount] stringValue]],
                          nil];

    return [NSArray arrayWithObject:[FWDetailListSection sectionForElements:infoSect withTitle:@"Last Update Details"]];
}

@end
